package com.cg.controller;

import com.cg.dto.*;
import com.cg.entity.DmItemType;
import com.cg.service.DmItemService;
import com.cg.service.DmItemTypeService;
import com.cg.vo.*;
import com.cg.vo.floor.FloorItemsVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 节目表(DmItem)表控制层
 *
 * @author makejava
 * @since 2023-11-08 13:00:44
 */
@RestController
@RequestMapping("/p/index")
public class DmItemController {
    /**
     * 服务对象
     */
    @Resource
    private DmItemService dmItemService;

    @Resource
    private DmItemTypeService dmItemTypeService;


    //获取所有的商品分类
    @PostMapping("/queryAllType")
    public Dto<List<ItemInfoVo>> findItemAll(){
        return dmItemService.findItemAll();
    }



    //获取首页横向导航数据
    @PostMapping("/queryTransverse")
    public Dto<List<DmItemType>> queryTransverse() {
        return dmItemTypeService.queryTransverse();
    }



    //首页轮播图接口
    @PostMapping("/queryBanner")
    public Dto<List<HotItems>> queryBanner() {
        return dmItemService.queryBanner();
    }


    //今日推荐列表
    @PostMapping("/queryTodayRecommend")
    public Dto<List<BannerVo>> queryTodayRecommend() {
        return dmItemService.queryTodayRecommend();
    }


    //即将开售列表
    @PostMapping("/queryToSaleItem")
    public Dto<List<BannerVo>> queryToSaleItem() {
        return dmItemService.queryToSaleItem();
    }


    //首页返回不同楼层展示数据
    @PostMapping("/queryFloorItems")
    public Dto<List<FloorItemsVo>> queryFloorItems() {
        return dmItemService.queryFloorItems();
    }


    //不同分类排行
    @PostMapping("/queryHotItems")
    public Dto<List<HotsVo>> queryHotitems(@RequestBody HotDto hotDto){
        return dmItemService.queryHotitems(hotDto);
    }


    //1. 根据分类查询轮播图
    @PostMapping("/querySlideShowPic")
    public Dto<List<HotItems>> querySlideShowPic(HotDto hotDto){
        return dmItemService.querySlideShowPic(hotDto);
    }


    //根据商品ID返回商品详情页
    @PostMapping("/queryItemDetail")
    public Dto<ItemDetailVo> queryItemDetail(@RequestBody ItemDetailDto itemDetailDto){
        return dmItemService.queryItemDetail(itemDetailDto.getId());
    }


    //根据商品id查询商品排期
    @PostMapping("/queryItemScheduler")
    public Dto<List<ItemSchedulerVo>> queryItemScheduler(@RequestBody ItemSchedulerDto itemSchedulerDto){
        return dmItemService.queryItemScheduler(itemSchedulerDto);
    }


    //根据商品排期查询商品价格
    @PostMapping("/queryItemPrice")
    public Dto<List<ItemPriceVo>> queryItemPrice(@RequestBody ItemPriceDto itemPriceDto){
        return dmItemService.queryItemPrice(itemPriceDto);
    }


    //根据商品id查询剧评
    @PostMapping("/queryItemComment")
    public Dto<List<ItemCommentVo>> queryItemComment(@RequestBody ItemCommentDto itemCommentDto){
        return dmItemService.queryItemComment(itemCommentDto);
    }


    //添加评论
    @PostMapping("/commitItemComment")
    public Dto addItemComment(@RequestBody AddItemCommentDto addItemCommentDto){
        return dmItemService.addItemComment(addItemCommentDto);
    }


    //推荐接口
    @PostMapping("/queryItemRecommend")
    public Dto<List<ItemRecommendVo>> queryItemRecommend(@RequestBody ItemRecommendDto itemRecommendDto){
        return dmItemService.queryItemRecommend(itemRecommendDto);
    }


    //查询分类接口
    @PostMapping("/queryItemType")
    public Dto<List<QueryItemTypeVo>> queryItemType(@RequestParam("parent") Long parent){
        return dmItemService.queryItemType(parent);
    }



    //猜你喜欢接口
    @PostMapping("/queryItemLike")
    public Dto<List<QueryItemLikeVo>> queryItemLike(@RequestParam("itemTypeId") Long itemTypeId){
        return dmItemService.queryItemLike(itemTypeId);
    }


    @PostMapping("/queryItemByMonth")
    public Dto<List<DayItemVo>> queryItemByMonth(@RequestBody DayItemDto dto){
        return DtoUtil.returnDataSuccess(dmItemService.queryItemByMonth(dto));
    }
}

